package flc.ast.fragment;

import android.os.Bundle;

import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.blankj.utilcode.util.ToastUtils;

import flc.ast.R;
import flc.ast.activity.AppTransferActivity;
import flc.ast.activity.SelAudioActivity;
import flc.ast.activity.SelPicActivity;
import flc.ast.activity.SelVideoActivity;
import flc.ast.databinding.FragmentToolBinding;
import stark.common.basic.base.BaseNoModelFragment;
import stark.common.basic.event.EventStatProxy;
import stark.common.basic.event.usersys.IUserSysEvent;
import stark.common.basic.event.usersys.UserSysEventProxy;

/**
 * A simple {@link Fragment} subclass.
 * Use the {@link ToolFragment#newInstance} factory method to
 * create an instance of this fragment.
 */
public class ToolFragment extends BaseNoModelFragment<FragmentToolBinding> {


    @Override
    protected int onCreate() {
        return R.layout.fragment_tool;
    }

    @Override
    protected void initView() {
        EventStatProxy.getInstance().statEvent5(getActivity(), mDataBinding.event5Container);

        mDataBinding.llPictureOri.setOnClickListener(this);
        mDataBinding.llPicturePuzzle.setOnClickListener(this);
        mDataBinding.llPictureSpecial.setOnClickListener(this);
        mDataBinding.llPictureWater.setOnClickListener(this);
        mDataBinding.llPictureMosaic.setOnClickListener(this);
        mDataBinding.llVideoSplice.setOnClickListener(this);
        mDataBinding.llVideoCompress.setOnClickListener(this);
        mDataBinding.llVideoFormat.setOnClickListener(this);
        mDataBinding.llVideoText.setOnClickListener(this);
        mDataBinding.llVideoSpeed.setOnClickListener(this);
        mDataBinding.llAudioSplice.setOnClickListener(this);
        mDataBinding.llAudioExtract.setOnClickListener(this);
        mDataBinding.llAudioFormat.setOnClickListener(this);
        mDataBinding.llAudioSpeed.setOnClickListener(this);
    }

    @Override
    protected void onClickCallback(View v) {
        switch (v.getId()) {
            case R.id.llPictureOri://长图拼接
                SelPicActivity.type = 0;
                SelPicActivity.isMore = true;
                startActivity(SelPicActivity.class);
                break;
            case R.id.llPicturePuzzle://自由拼接
                UserSysEventProxy.getInstance().payEvent(getActivity(), new IUserSysEvent.IPayEventCallback() {
                    @Override
                    public void onPayOk(boolean isRealOk) {
                        if (isRealOk) {
                            SelPicActivity.type = 1;
                            SelPicActivity.isMore = true;
                            startActivity(SelPicActivity.class);
                        } else {
                            ToastUtils.showShort(getString(R.string.not_vip));
                        }
                    }
                });
                break;
            case R.id.llPictureSpecial://图片特效
                UserSysEventProxy.getInstance().payEvent(getActivity(), new IUserSysEvent.IPayEventCallback() {
                    @Override
                    public void onPayOk(boolean isRealOk) {
                        if (isRealOk) {
                            SelPicActivity.type = 2;
                            SelPicActivity.isMore = false;
                            startActivity(SelPicActivity.class);
                        } else {
                            ToastUtils.showShort(getString(R.string.not_vip));
                        }
                    }
                });
                break;
            case R.id.llPictureWater://图片水印
                UserSysEventProxy.getInstance().payEvent(getActivity(), new IUserSysEvent.IPayEventCallback() {
                    @Override
                    public void onPayOk(boolean isRealOk) {
                        if (isRealOk) {
                            SelPicActivity.type = 3;
                            SelPicActivity.isMore = false;
                            startActivity(SelPicActivity.class);
                        } else {
                            ToastUtils.showShort(getString(R.string.not_vip));
                        }
                    }
                });
                break;
            case R.id.llPictureMosaic://图片打码
                SelPicActivity.type = 4;
                SelPicActivity.isMore = false;
                startActivity(SelPicActivity.class);
                break;
            case R.id.llVideoSplice://视频拼接
                SelVideoActivity.type = 0;
                startActivity(SelVideoActivity.class);
                break;
            case R.id.llVideoCompress://视频压缩
                UserSysEventProxy.getInstance().payEvent(getActivity(), new IUserSysEvent.IPayEventCallback() {
                    @Override
                    public void onPayOk(boolean isRealOk) {
                        if (isRealOk) {
                            SelVideoActivity.type = 1;
                            startActivity(SelVideoActivity.class);
                        } else {
                            ToastUtils.showShort(getString(R.string.not_vip));
                        }
                    }
                });
                break;
            case R.id.llVideoFormat://视频格式转换
                SelVideoActivity.type = 2;
                startActivity(SelVideoActivity.class);
                break;
            case R.id.llVideoText://视频添加文字
                SelVideoActivity.type = 3;
                startActivity(SelVideoActivity.class);
                break;
            case R.id.llVideoSpeed://视频变速
                SelVideoActivity.type = 4;
                startActivity(SelVideoActivity.class);
                break;
            case R.id.llAudioSplice://音频拼接
                SelAudioActivity.type = 0;
                startActivity(SelAudioActivity.class);
                break;
            case R.id.llAudioExtract://音频提取
                UserSysEventProxy.getInstance().payEvent(getActivity(), new IUserSysEvent.IPayEventCallback() {
                    @Override
                    public void onPayOk(boolean isRealOk) {
                        if (isRealOk) {
                            SelVideoActivity.type = 5;
                            startActivity(SelVideoActivity.class);
                        } else {
                            ToastUtils.showShort(getString(R.string.not_vip));
                        }
                    }
                });
                break;
            case R.id.llAudioFormat://音频格式转换
                SelAudioActivity.type = 1;
                startActivity(SelAudioActivity.class);
                break;
            case R.id.llAudioSpeed://音频变速
                SelAudioActivity.type = 2;
                startActivity(SelAudioActivity.class);
                break;
        }
    }

    @Override
    protected void initData() {

    }
}